<?php
//将接受到的原始数据进行保存，其中on只要不改变机会永久保存，off会在下次删除
class FileAction{
    protected $fileObject='';
    //打开文件
    protected function Opens($fileName){
        $this->fileObject=fopen($fileName,"r+");
    }
    //读取文件
    static public function Read($fileName){
       $file=new Reads($fileName);
       return $file->fileRead();
    }
    //写入文件
    static public function Write($fileName,$fileArray){
        new Writes($fileName,$fileArray);
    }
}
class Reads extends FileAction{
    private $fileName='';
    public function __construct($fileName){
        $this->fileName=$fileName;
    }
    public function fileRead(){
        $this->Opens($this->fileName);
        $content=fread($this->fileObject,filesize($this->fileName));
        fclose($this->fileObject);
        return $content;
    }
}
class Writes extends FileAction{
    public function __construct($fileName,$fileArray){
        return $this->fileWrite($fileName,$fileArray);
    }
    protected function fileWrite($fileName,$fileArray){
        file_put_contents($fileName,JsonAction::Encode($fileArray));
    }
}
?>